<?php
/**
 * 评论模板
 *
 * 用于列表评论和显示评论表单
 *
 * @package one
 * @subpackage Template
 */

	if ( 'comments.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) )
		die( __('Please do not load this page directly. Thanks!', 'one' ) );

	if ( post_password_required() ) :
		echo '<h3 class="comments-header">' . __('Password Protected', 'one') . '</h3>';
		echo '<p class="alert password-protected">' . __('Enter the password to view comments.', 'one') . '</p>';
		return;
	endif;

	if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
		return;
?>
<div id="comments-template">

<?php if ( have_comments() ) : ?>

	<div id="comments">
	
		<h3 id="comments-number" class="comments-header">
			<?php comments_number( sprintf( __('%1$s暂时没有评论', 'one'), the_title( '&#8220;', '&#8221;', false ) ), sprintf( __('%1$s的沙发木有鸟~', 'one'), the_title( '&#8220;', '&#8221;', false ) ), sprintf( __('有%1$s个童鞋跑来唧唧歪歪%2$s', 'one'), '%', the_title( '&#8220;', '&#8221;', false ) ) ); ?>
		</h3>

		<ol id="thecomments" class="comment-list">
			<?php wp_list_comments(
				array(
					'style' => 'ol',
					'type' => 'all',
					'callback' => 'one_comments_callback',
					'end-callback' => 'one_comments_end_callback'
				)
			); ?>
		</ol>


		<?php if ( get_option( 'page_comments' ) ) : ?>
			<div class="paged-navigation">
				评论分页：<?php paginate_comments_links(); ?>
			</div>
		<?php endif; ?>

	</div>

<?php else : ?>

	<?php if ( pings_open() && !comments_open() && is_single() ) : ?>

		<p class="comments-closed pings-open">
			<?php printf( __('评论已经关闭，但是 <a href="%1$s" title="Trackback URL for this post">trackbacks</a>和pingbacks是开启的', 'one'), trackback_url( '0' ) ); ?>
		</p>

	<?php elseif ( !comments_open() && is_single() ) : ?>

		<p class="comments-closed">
			<?php _e('评论已经关闭', 'one'); ?>
		</p>

	<?php endif; ?>

<?php endif; ?>

<script type="text/javascript">
/* <![CDATA[ */
ajaxCommentsURL = "<?php bloginfo('template_url'); ?>/comments-ajax.php";
/* ]]> */
</script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/comments.js"></script>

<?php if ( comments_open() ) : ?>

	<div id="respond">

		<h3 id="reply">
			<?php comment_form_title( __('我要说两句', 'one'), __('关于%s我要说两句', 'one'), true ); ?>
		</h3>

		<p id="cancel-comment-reply">
			<?php cancel_comment_reply_link( __('点击这里取消回复', 'one') ); ?>
		</p>

	<?php if ( get_option( 'comment_registration' ) && !$user_ID ) : ?>

		<p class="alert">
			<?php printf( __('你必须要<a href="%1$s" title="Log in">登陆</a>才能发表评论。', 'one'), wp_login_url( get_permalink() ) ); ?>
		</p>

	<?php else : ?>

		<form action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php" method="post" id="commentform">

			<?php if ( $user_ID ) : ?>

				<p class="log-in-out">
					<?php printf( __('已经以<a href="%1$s" title="%2$s">%2$s</a>的身份登录。', 'one'), get_option( 'siteurl' ) . '/wp-admin/profile.php', $user_identity ); ?> <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="<?php _e('登出此帐户', 'one'); ?>"><?php _e('注销登录状态 &raquo;', 'one'); ?></a>
				</p>

			<?php else : ?>
				<?php if ( $comment_author != "" ) : ?>
				<script type="text/javascript" charset="utf-8">
					//<![CDATA[
						var changeMsg = "<?php _e('编辑信息 &raquo;','one'); ?>";
						var closeMsg = "<?php _e('Close &raquo;','one'); ?>";
					//]]>
					</script>
					<div class="form-welcome">
						<?php echo get_avatar($comment_author_email, 32); printf(__('口爱滴<strong>%s</strong>童鞋，欢迎回来', 'one'), $comment_author) ?>
						<span id="show_author_info"><a href="javascript:void(0);"><?php _e('Change &raquo;','one'); ?></a></span>
						</div>
				<?php endif; ?>
				<div id="author_info"<?php if ( $comment_author != "" ) echo ' style="display:none"';?>>
					<p class="form-author">
						<label for="author"><?php _e('Name', 'one'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'one'); ?></span><?php endif; ?></label>
						<input type="text" class="text-input" name="author" id="author" value="<?php echo $comment_author; ?>" size="40" tabindex="1" />
					</p>

					<p class="form-email">
						<label for="email"><?php _e('Email', 'one'); ?>  <?php if ( $req ) : ?><span class="required"><?php _e('*', 'one'); ?></span><?php endif; ?></label>
						<input type="text" class="text-input" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="40" tabindex="2" />
					</p>

					<p class="form-url">
						<label for="url"><?php _e('Website', 'one'); ?></label>
						<input type="text" class="text-input" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="40" tabindex="3" />
					</p>
				</div>
			<?php endif; ?>
			
			<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/edit_button.js"></script>
			<script type="text/javascript">edToolbar('comment');</script>
			<p class="form-textarea">
				<label for="comment"><?php _e('Comment', 'one'); ?></label>
				<textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>
				<div id="commentload" class="center" style="display:none;">
					<img src="<?php bloginfo('template_url'); ?>/image/ajax-loader.gif" alt="loading" /> <?php _e('正在提交评论，请稍候。。。','one')?>
				</div>
			</p>

			<p class="form-submit">
				<input class="submit-comment button" name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('提交', 'one'); ?>" />
				<input class="reset-comment button" name="reset" type="reset" id="reset" tabindex="6" value="<?php _e('重填', 'one'); ?>" />
				<?php comment_id_fields(); ?>
			</p><?php if (function_exists('highslide_emoticons')) : ?>
				<div id="emoticon"><?php highslide_emoticons(); ?></div>
			<?php endif; ?>
			
			<div class="comment-action">
				<?php do_action( 'comment_form', $post->ID ); ?>
			</div>

		</form>

	<?php endif; ?>

	</div>

<?php endif; ?>

</div>